package com.cat.dataStructure;

import java.util.PriorityQueue;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/maximal-score-after-applying-k-operations/
 * @create 2025/10/4 21:09
 * @since JDK17
 */

public class Solution94 {
    public long maxKelements(int[] nums, int k) {
        PriorityQueue<Integer> heap = new PriorityQueue<>((a, b) -> b - a);
        long ans = 0;
        for (var num : nums) {
            heap.add(num);
        }
        for (int i = 0; i < k; i++) {
            Integer num = heap.poll();
            ans += num;
            heap.add(num / 3);
        }
        return ans;
    }
}
